package com.sun.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sun.dao.FloorMapper;
import com.sun.dao.MenuMapper;
import com.sun.pojo.Floor;
import com.sun.pojo.Menu;
import com.sun.service.FloorService;
import com.sun.service.MenuService;
import com.sun.utils.DataGridViewResult;
import com.sun.vo.FloorVo;
import com.sun.vo.MenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class FloorServiceImpl implements FloorService {

    @Autowired
    private FloorMapper floorMapper;

    public DataGridViewResult findAll(FloorVo floorVo) {
        PageHelper.startPage(floorVo.getPage(),floorVo.getLimit());
        List<Floor> all = floorMapper.findAll(floorVo);
        PageInfo<Floor> pageInfo = new PageInfo<Floor>(all);
        return new DataGridViewResult(pageInfo.getTotal(),pageInfo.getList());
    }

    public int addFloor(Floor floor) {
        return floorMapper.addFloor(floor);
    }

    public int updateFloor(Floor floor) {
        return floorMapper.updateFloor(floor);
    }

    public List<Floor> initRoomSelectFloor() {
        return floorMapper.findAll(null);
    }

    public List<Floor> initAll() {
        return floorMapper.initAll();
    }
}
